package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbOfferContactor;
import org.apache.ibatis.annotations.Insert;

/**
 * 紧急联系人数据库访问层
 *
 * @author chenyifan
 * @since 2022-06-06 10:06:47
 */
public interface TbOfferContactorMapper extends BaseMapper<TbOfferContactor> {

    @Insert("INSERT INTO tb_offer_contactor \n" +
            "(contactor_id, worker_id, relation_type , contactor_name, contactor_address, \n" +
            "contactor_phone, update_time, offer_id, already_save) \n" +
            "SELECT \n" +
            "nextval('hrssseq'), a.HC_NO, NULL, b.ContactsName, b.ContactsAddress, \n" +
            "CASE WHEN length(b.ContactsTel) != 11 THEN '' ELSE b.ContactsTel END, \n" +
            "NOW(), b.OfferID, 0 \n" +
            "FROM Offer_Send_Detail a, Offer_ContactsInfo b \n" +
            "WHERE a.id= b.OfferID" )
    void initContactorRecordFromHrss();
}

